<!--tvm票款差异协查-->
<template>
  <div class="TvmJiezhangdanjuxiecha el-card is-always-shadow el-card__body">
    <el-dialog
      title="操作回馈信息"
      :visible.sync="dialogVisible"
      @close="closed"
      width="950px">
      <avue-form v-if="isReload" class="TvmJiezhangdanjuxiechaForm" :option="option" v-model="formData" @submit="handleSubmit">
        <template slot-scope="scope" slot="electromeReason">
          <el-select v-model="electromeReason" placeholder="请选择" style="width: 150px" disabled="true">
            <el-option
              v-for="(item,index) in electromeReasons"
              :key="index"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>
        <template slot-scope="scope" slot="menuForm">
          <el-button type="primary" @click="closed">返回</el-button>
        </template>
      </avue-form>
    </el-dialog>
  </div>
</template>


<script>
  import {getForm, postForm} from '@/api/gen/gen'
  import ExportJsonExcel from "js-export-excel";
  import {
    getSwAuTvmDailyBillAssistDetail,
    setSwAuTvmDailyBillAssistDetail
  } from "../../../../../api/subwayRat/TVMRevenueVarianceAudit.TvmChaYiDXC/TvmJiezhangdanjuxiecha";
  import {electromeReasons, fenExYuangettoFixed, qianxiangType} from "../../../../../api/subwayRat/commonCheck";

  export default {
    components:{
    },
    data() {
      return {
        masterId:'',//主表Id
        isReload:true,
        //1编辑，2添加，3预览
        showType:1,
        electromeReason:'',
        electromeReasons:[],
        dialogVisible:true,
        formData:{
        },
        option:{

        }
    }
    },
    created() {
        this.electromeReasons = electromeReasons();
    },
    methods: {
      handleSubmit(form,done){
        setSwAuTvmDailyBillAssistDetail({ids:this.masterId}).then(res=>{
          if(res.data.code==0){
            this.$message.success("操作成功！");
            this.closed();
            this.$parent.getList();
            this.$parent.cancelChoose();
          }else{
            this.$message.error(res.data.msg);
          }
        }).catch(e=>{
          this.$message.error("操作失败！");
        });
        done();
      },
      recallShow(id,row,showType){
        this.masterId=id;
        this.showType=showType;
        this.getOption();
        this.formData={}
       Object.assign(this.formData,row);
        getSwAuTvmDailyBillAssistDetail({relationid:id}).then((res)=>{
          if(res.data.code!=0){
              this.$message.error("获取数据失败！");
              return;
          }
          if(res.data.data.length>0){
            let r=this.fenZhuanYuan(res.data.data[0]);
            Object.assign(this.formData,r); //
          }
        }).catch((e)=>{
          this.$message.error("获取数据失败！");
        })
        this.electromeReason=row.electromeReason;
      },
      fenZhuanYuan(row){
        row.rReceiveNotes=fenExYuangettoFixed(row,'rReceiveNotes');
        row.rReceiveCoin=fenExYuangettoFixed(row,'rReceiveCoin');
        row.rReceiveMoney=fenExYuangettoFixed(row,'rReceiveMoney');
        row.rNoteChange=fenExYuangettoFixed(row,'rNoteChange');
        row.rCoinChange=fenExYuangettoFixed(row,'rCoinChange');
        row.rChangeTotalMoney=fenExYuangettoFixed(row,'rChangeTotalMoney');
        row.rSellTicketMoney=fenExYuangettoFixed(row,'rSellTicketMoney');
        row.rRechargeTotal=fenExYuangettoFixed(row,'rRechargeTotal');
        row.rReturnTotal=fenExYuangettoFixed(row,'rReturnTotal');
        row.eSellTicketMoney=fenExYuangettoFixed(row,'eSellTicketMoney');
        row.eRechargeTotal=fenExYuangettoFixed(row,'eRechargeTotal');
        row.eReturnTotal=fenExYuangettoFixed(row,'eReturnTotal');
        return row;
      },
      closed(){
        this.dialogVisible=false;
        this.$parent.isShowDia=false;
      },
      getOption(){
        this.option={
          submitBtn:true,
          emptyBtn:false,
          submitText:'一键替换',
          span:12,
          group:[
            {
              icon:'',
              label: '',
              // collapse:false,
              prop: 'group1',
              column: [{
                label: 'TVM编号',
                prop: 'tvmCode',
                type: 'input',
                width:250,
                labelWidth:110,
                disabled: this.showType==3
              },{
                label: '结账开始时间',
                prop: 'incomeSettleBeginTime',
                type: 'datetime',
                format: 'yyyy-MM-dd',
                valueFormat: 'yyyy-MM-dd',
                width:250,
                labelWidth:110,
                disabled: this.showType==3
              },{
                label: '结账结束时间',
                prop: 'incomeSettleEndTime',
                format: 'yyyy-MM-dd',
                valueFormat: 'yyyy-MM-dd',
                width:'250',
                labelWidth:110,
                disabled: this.showType==3
              }]
            },
            {
              icon:'',
              label: '现金支付',
              // collapse:false,
              prop: 'group2',
              column:[{
                label: '接收纸币',
                prop: 'rReceiveNotes',
                type: 'number',
                labelWidth:110,
                precision:2,
                disabled: this.showType==3
              }, {
                label: '接收硬币',
                prop: 'rReceiveCoin',
                type: 'number',
                labelWidth:110,
                precision:2,
                disabled: this.showType==3
              },
                {
                  label: '接收统计',
                  prop: 'rReceiveMoney',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==3
                },
                {
                  label: '纸币找零',
                  prop: 'rNoteChange',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==3
                }, {
                  label: '硬币找零',
                  prop: 'rCoinChange',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==3
                },
                {
                  label: '找零统计',
                  prop: 'rChangeTotalMoney',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==3
                },{
                  label: '售票金额',
                  prop: 'rSellTicketMoney',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==3
                }, {
                  label: '充值金额',
                  prop: 'rRechargeTotal',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==3
                },
                {
                  label: '退款金额',
                  prop: 'rReturnTotal',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==3
                }]
            },
            {
              icon:'',
              label: '电子支付',
              // collapse:false,
              prop: 'group3',
              column:[{
                label: '售票金额',
                prop: 'eSellTicketMoney',
                type: 'number',
                labelWidth:110,
                precision:2,
                disabled: this.showType==3
              },
                {
                  label: '充值金额',
                  prop: 'eRechargeTotal',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==3
                },
                {
                  label: '退款金额',
                  prop: 'eReturnTotal',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==3
                }
              ]
            },
            {
              icon:'',
              label: '原因备注',
              // collapse:false,
              prop: 'group4',
              column:[{
                label: '归属机电专业回馈原因',
                prop: 'electromeReason',
                type: 'select',
                labelWidth:180,
                span: 8,
                formslot:true,
                disabled: this.showType==3
              },
                {
                  label: '备注',
                  prop: 'remark',
                  type: '`',
                  labelWidth:110,
                  disabled: this.showType==3
                }
              ]
            }

          ]
        } ;
        this.isReload=false;
        this.$nextTick(()=>{
          this.isReload=true;
        })
      }
    },
    mounted() {

    }
  }
</script>
<style lang="scss">
  .TvmJiezhangdanjuxiecha{
    .TvmJiezhangdanjuxiechaForm{
      .el-form-item{
        min-width: 150px;
      }
      .avue-form__row{
        width: 30%;
      }
      .avue-group[index='4']{
        .el-form-item{
          min-width: 450px;
        }
        .avue-form__row{
          width: 70%;
        }
      }
    }
  }

</style>
